package com.hqd.ch03.v48.boot.context.properties.bind;

import com.hqd.ch03.v48.boot.context.properties.source.ConfigurationPropertyName;

interface DataObjectBinder {

    /**
     * Return a bound instance or {@code null} if the {@link DataObjectBinder} does not
     * support the specified {@link Bindable}.
     *
     * @param name           the name being bound
     * @param target         the bindable to bind
     * @param context        the bind context
     * @param propertyBinder property binder
     * @param <T>            the source type
     * @return a bound instance or {@code null}
     */
    <T> T bind(ConfigurationPropertyName name, Bindable<T> target, Binder.Context context,
               DataObjectPropertyBinder propertyBinder);

    /**
     * Return a newly created instance or {@code null} if the {@link DataObjectBinder}
     * does not support the specified {@link Bindable}.
     *
     * @param target  the bindable to create
     * @param context the bind context
     * @param <T>     the source type
     * @return the created instance
     */
    <T> T create(Bindable<T> target, Binder.Context context);

}

